<style src="./index.scss" lang="scss" scoped rel="stylesheet/scss"></style>
<template src="./index.html"></template>
<script>
export default {
    props: {
        // 使用者window实例 必定义
        appWindow: {
            type: Object,
            default: null,
        },
        value: {
            type: String,
            default: "",
        },
    },
    computed: {
        dataObj() {
            let _d = {};
            if (!this.$vFN.Utils.isEmpty(this.value)) {
                try {
                    _d = JSON.parse(this.value);
                } catch (e) {}
            }

            return {
                name: _d["name"],
                path: _d["path"],
                type: _d["type"],
                query: _d["query"],
            };
        },
    },
    data() {
        return {
            list: [],
            boxVisible: false,
        };
    },
    methods: {
        getQuery() {
            let _query = this.dataObj.query;
            if (!this.$vFN.Utils.isEmpty(_query)) {
                let _d = [];
                for (let i in _query) {
                    _d.push(i + "=" + _query[i]);
                }
                return "?" + _d.join("&");
            } else {
                return "";
            }
        },
        selectLink(item_, index_) {
            this.$vFN.Directives.SelectLink({
                appWindow: this.appWindow,
                selected: JSON.stringify(this.dataObj),
                onSuccess: (res) => {

                    
                    this.$emit("input", res);
                },
            });
        },
        delLink(){
            this.$emit("input", "");
        },
    },
    watch: {},
    mounted() {},
    beforeCreate() {},
};
</script>
